﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using UT3Bots.Visualizer.Visualizer.UTItems;
using System.Collections.ObjectModel;
using UT3Bots.UTItems;

namespace UT3Bots.Visualizer.Controls
{
	public partial class UTUIScoreControl : UserControl
	{
		public UTUIScoreControl()
		{
			InitializeComponent();
		}

		private void Button_Click(object sender, RoutedEventArgs e)
		{
			if (gridHolder.Visibility == Visibility.Collapsed)
			{
				gridHolder.Visibility = Visibility.Visible;
				//stackScores.Visibility = Visibility.Collapsed;
			}
			else
			{
				gridHolder.Visibility = Visibility.Collapsed;
				//stackScores.Visibility = Visibility.Visible;
			}
		}

		public void Sort(Dictionary<UTIdentifier, UTUIScore> items)
		{
			var scores = items.Select(s => s.Value);
			var scores2 = scores.OrderByDescending(s => s.Score);

			int i = 1;
			foreach (var s in scores2)
			{
				s.Position = i;
				i++;
			}
			gridScores.ItemsSource = scores2;
		}


	}
}
